import time

from appium.webdriver.common.appiumby import AppiumBy
from Util.BasePage import BasePage


class ZfbDoubleClick(BasePage):

    myslIcon = (AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("蚂蚁森林")')
    qubaohuTxt1 = (AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().textContains("去保护")')
    closeBeiBao = (AppiumBy.XPATH, '//android.widget.Button[@text="关闭"]')
    doubleCard = (AppiumBy.XPATH, '//android.widget.TextView[@text="能量双击卡"]')
    duihuan = (AppiumBy.XPATH, '//android.widget.TextView[@text="立即兑换"]')
    xianshiDC = (AppiumBy.XPATH, '//android.widget.TextView[@text="限时双击卡"]')
    usedone = (AppiumBy.XPATH, '(//android.widget.TextView[@text="使用"])[1]')  # self.driver.tap([(540, 1140)])
    usedImmd = (AppiumBy.XPATH, '//android.widget.Button[@text="立即使用"]')  # 立即使用

    def DC_beibaoIc(self):
        time.sleep(1)
        self.driver.tap([(245, 1575)])  # 背包坐标
        time.sleep(1.5)
        self.driver.tap([(200, 999)])  # 兑换坐标
        time.sleep(2.5)
        # 兑换页面
        self.click(self.doubleCard)

        # shaungji
        time.sleep(1.5)
        self.click(self.duihuan)  # lijiduihuan
        time.sleep(0.8)
        #
        self.driver.tap([(727, 1222)])  # 确认对换
        time.sleep(1)
        self.driver.tap([(730, 1166)])  # 立即使用

        time.sleep(3)
        self.click(self.usedone)

        # 限时双击卡使用点击
        time.sleep(1)
        self.click(self.usedImmd)  # 立即使用
        time.sleep(1)
        self.click(self.closeBeiBao)
        time.sleep(0.5)













